package com.example.a79273.shandianban.client;

import android.util.Log;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

/**
 * Created by Bob on 2016/7/25.
 */
public class MyChormeClient extends WebChromeClient {
    private ChormeCallBack mCallBack;
    public interface  ChormeCallBack{
         void onProgressChanged(int progress);
         void onReceivedTitle(String title);
    }
    /*public  MyChormeClient(ChormeCallBack callBack){
        mCallBack = callBack;
    }*/

    public void setChormeListener(ChormeCallBack chormeListener){
        mCallBack = chormeListener;
    };
    // 用于监听 网页加载进度（以方便设置加载进度，给用户）
    @Override
    public void onProgressChanged(WebView view, int newProgress) {
        super.onProgressChanged(view, newProgress);
        if (mCallBack!=null){
            mCallBack.onProgressChanged(newProgress);

        }
        Log.d("tag","onProgressChanged == " +newProgress);
    }
     //用于接收Webview传回来的网页标题，来展示在我们自己的app里面。
    @Override
    public void onReceivedTitle(WebView view, String title) {
        super.onReceivedTitle(view, title);
        if (mCallBack!=null){
            mCallBack.onReceivedTitle(title);
        }
        Log.d("tag","onReceivedTitle == "+title);
    }
}
